#include <stdio.h>
using namespace std;

int main()
{
    int month_list[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    int year, days;
    while (scanf(" %d %d", &year, &days) != EOF) {
        if (year % 4 == 0 && year % 100 != 0)
            month_list[1] = 29;
        else if (year % 400 == 0)
            month_list[1] = 29;
        else
            month_list[1] = 28;

        int i;
        if (days < month_list[0]) {
            i = -1;
        } else {
            for (i = 0; i < 12; i++) {
                days -= month_list[i];
                if (days <= month_list[i + 1])
                    break;            
            }
        }
        printf("%04d-%02d-%02d\n", year, i + 2, days);
    }

    return 0;
}